package routers

import (
	"cmt1-admin/controllers"

	"github.com/gin-gonic/gin"
)

func Router() *gin.Engine {
	r := gin.New()
	// router := r.Default()
	r.Use(controllers.Cors())
	r.Use(gin.Logger())

	r.GET("/mytest", controllers.MyTest)

	r.POST("/user/login", controllers.UserLogin)
	r.GET("/user/info", controllers.UserInfo)
	// r.POST("/user/logout", controllers.UserLogout)
	users := r.Group("/user")
	users.Use(controllers.JWTAuth())
	{
		users.POST("/logout", controllers.UserLogout)
		users.POST("/mail", controllers.SendMail)
		users.GET("/uid/:uid", controllers.GetUserInfoByUid)
		users.GET("/list", controllers.GetUserList)
		users.POST("/modify", controllers.SetUserInfo)
		users.GET("/onlineNum", controllers.GetOnlineNum)
		users.GET("/closure", controllers.SetClosureTime)
		users.POST("/white", controllers.SetWhite)
		users.GET("/newUser", controllers.GetNewUser) // 新增玩家数
		users.GET("/payUser", controllers.GetPayUser) // 付费玩家数
		users.GET("/income", controllers.GetIncome)   // 收入
	}
	//添加用户宠物路由
	userPet := r.Group("/userPet")
	userPet.Use(controllers.JWTAuth())
	{
		userPet.GET("/info/:uid", controllers.GetUserPetInfoByUid)
		userPet.GET("/list", controllers.GetUserPetList)
		userPet.POST("/modify", controllers.SetUserPetInfo)
	}

	userHero := r.Group("/userHero")
	userHero.Use(controllers.JWTAuth())
	{
		userHero.GET("/info/:uid", controllers.GetHerosByUid)
	}

	union := r.Group("/union")
	union.Use(controllers.JWTAuth())
	{
		union.GET("/info/:uid", controllers.GetUnionInfoByUid)
		// union.GET("/unionInfo/:uid", controllers.GetUnionInfoByUid)
		union.GET("/members", controllers.GetUnionMembersByUid)
		union.GET("/list", controllers.GetUnionList)
	}

	// 活动礼包，兑换码
	activPack := r.Group("/activPack")
	activPack.Use(controllers.JWTAuth())
	{
		activPack.POST("/setAcitvPack", controllers.SetAcitvPack)
		activPack.GET("/getAcitvPack", controllers.GetAcitvPack)
		activPack.POST("/updateAcitvPack", controllers.UpdateAcitvPack)
		activPack.POST("/deleteAcitvPack", controllers.DeleteAcitvPack)
		activPack.POST("/addAcitvPack", controllers.AddAcitvPack)
		activPack.GET("/getExCode", controllers.GetExCode)
	}

	logList := r.Group("/log")
	logList.Use(controllers.JWTAuth())
	{
		logList.GET("/wabao", controllers.GetWabaoLogList)        //挖宝日志
		logList.GET("/fire", controllers.GetFireLogList)          //攻击日志（放火）
		logList.GET("/befire", controllers.GetBeFireLogList)      //被攻击日志（被烧）
		logList.GET("/theft", controllers.GetTheftLogList)        //偷盗日志
		logList.GET("/betheft", controllers.GetBeTheftLogList)    //被偷日志
		logList.GET("/slot", controllers.GetSlotLogList)          //老虎机日志
		logList.GET("/shop", controllers.GetShopLogList)          //商店日志
		logList.GET("/hideshop", controllers.GetHideShopLogList)  //隐藏商店日志
		logList.GET("/userDaily", controllers.GetUserDailyList)   //用户日常日志
		logList.GET("/userGold", controllers.GetUserGoldList)     //用户金币日志
		logList.GET("/userEnergy", controllers.GetUserEnergyList) //用户体力日志
		logList.GET("/userAddr", controllers.GetUserAddrList)     //用户体力日志
		logList.GET("/userDiamon", controllers.GetUserDiamonList) //用户钻石日志
		logList.GET("/payOrder", controllers.GetPayOrderList)     //支付订单 华为
		logList.GET("/mcpayOrder", controllers.GetMCPayOrderList) //支付订单 苹果和安卓
		logList.GET("/adCnt", controllers.GetAdCntList)           //广告统计
		logList.GET("/adUser", controllers.GetAdUserList)         //用户广告统计
	}

	myexcel := r.Group("/myexcel")
	myexcel.Use(controllers.JWTAuth())
	{
		myexcel.POST("/user", controllers.ExportExcel)
		// myexcel.StaticFS("/export", http.Dir(export.GetExcelFullPath()))
	}
	return r
}
